package com.first.agent.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.first.agent.common.R;
import com.first.agent.service.CustomerService;
import com.first.agent.service.impl.CustomerServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created with IntelliJ IDEA.
 * User: lxm
 * Date: 2022/11/16 16:01
 * Description:
 * Version: V1.0
 */
@WebServlet("/customer/open")
public class OpenCustomerServlet extends HttpServlet{
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String cus_id = req.getParameter("id");
        String state = req.getParameter("state0");
        //调用service
        CustomerService csi=new CustomerServiceImp();
        R r = csi.openCustomer(cus_id, state);

        //响应
        resp.setContentType("application/json;charset=utf-8");
        PrintWriter writer = resp.getWriter();
        writer.write(JSONObject.toJSONString(r));
        writer.flush();
        writer.close();
    }
}
